package com.catazy.mvvmlib.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.ViewDataBinding
import androidx.viewbinding.ViewBinding
import com.catazy.mvvmlib.base.viewmodel.BaseViewModel
import com.catazy.mvvmlib.ext.inflateBindingWithGeneric
import java.lang.reflect.ParameterizedType

/**
 * 作者: Tao
 * 日期: 2024/1/25
 * 时间: 9:36
 * 描述:
 */
abstract class BaseVmVbFragment<VM : BaseViewModel, VB : ViewBinding> : BaseVmFragment<VM>() {

    private var mDatabind: VB? = null

    /**
     * 当使用ViewBinding模式时，这里直接不传布局
     */
    override fun layoutId(): Int {
        return 0
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mDatabind = inflateBindingWithGeneric(container, false)
        return mDatabind!!.root
    }

    override fun onDestroy() {
        super.onDestroy()
        mDatabind = null
    }
}